package pl.elot.xml.parsers;

import net.grzechocinski.android.utils.DateFormatUtils;
import net.grzechocinski.android.xml.parser.AbstractParser;
import org.w3c.dom.Element;
import pl.elot.domain.*;

import java.util.Date;
import java.util.List;

/**
 * @author mateusz.grzechocinski@gmail.com
 * @since 2010-10-29
 */
public class PromotionParser extends AbstractParser<Promotion> {

    @Override
    public List<Promotion> unmarshallAll(Element root) {
        return super.unmarshallAll(root, "Promos");
    }

    @Override
    protected Promotion unmarshall() {

        Airport departureAirport = new Airport().withName().withCode().inCity().inCountry();
        Date departureDate = DateFormatUtils.parse(getElementValue(""));
        new Move(departureAirport, getElementValue(""));

        new FlightSegment.Builder()
                .departureFrom()
                .arrivalTo()
                .byAirline()
                .create();
        new Flight().addSegment();

        return new Promotion.Builder()
                .startsAt(getElementValue("dateStart"))
                .endsAt(getElementValue("dateEnd"))
                .byFlight()
                .withPrice()
                .create();

    }
}
